#include <stdio.h>
#include <stdarg.h>
#include <aio.h>
int m_printf(const char *fmt, ...)
{
    char *s;
    va_list ap;
    int arg_count;
    int i;
    
    va_start(ap, fmt);
    s = fmt;
    while ((s=strchr(s, '%'))) {
        if (s) {
            i++;
            s++;
            switch (*s) {
                case 's':
                    printf("Get a string argment.\n");
                    printf("arg[%d]:%s\n", i, va_arg(ap, char*));
                    break;
                case 'd':
                    printf("Get a int argment.\n");
                    printf("arg[%d]:%d\n", i, va_arg(ap, int));
                    break;
                case 'c':
                    printf("Get a char argment.\n");
                    printf("arg[%d]:%c\n", i, va_arg(ap, char*));
                    break;
                case 'f':
                    printf("Get a float argment.\n");
                    printf("arg[%d]:%f\n", i, va_arg(ap, double));
                    break;
            }
        } else {
            break;
        }
    }
    va_end(ap);

    //printf("%s\n", s);

    return 0;
}

int main(int argc, const char *argv[])
{
    int i = 10;
    float f = 11.1;
    char c = 'i';
    m_printf("%s%d%c%f\n", "li", i, c, f);   
    return 0;
}
